using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Graphics;
using Java.Net;

namespace jtgApp
{
    public class Tools
    {
        public static Bitmap getImage(string imagepath)
        {
            URL url = null;
            Bitmap bitmap = null;
            try
            {
                url = new URL(imagepath.Replace(" ", "%20"));
            }
            catch{
                return null;
            }
            try
            {
                HttpURLConnection conn = (HttpURLConnection)url.OpenConnection();
                conn.SetRequestProperty("User-agent", "Mozilla/4.0");
                conn.ReadTimeout = 6000;
                conn.DoInput = true;
                conn.UseCaches = true;
                conn.Connect();
                System.IO.Stream str = conn.InputStream;
                bitmap = BitmapFactory.DecodeStream(str);
                str.Close();
                return bitmap;
            }
            catch
            {
                return null;
            } 
        }
    }
}